<?php
$database = '';
$success_page = '';
$error_message = "";
if (!file_exists($database))
{
   die('User database not found!');
   exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['form_name'] == 'signupform')
{
   $newusername = $_POST['username'];
   $newemail = $_POST['email'];
   $newpassword = $_POST['password'];
   $confirmpassword = $_POST['confirmpassword'];
   $newfullname = $_POST['fullname'];
   $code = 'NA';
   if ($newpassword != $confirmpassword)
   {
      $error_message = '';
   }
   else
   if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newusername))
   {
      $error_message = '';
   }
   else
   if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newpassword))
   {
      $error_message = '';
   }
   else
   if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $newfullname))
   {
      $error_message = '';
   }
   else
   if (!ereg("^.+@.+\..+$", $newemail))
   {
      $error_message = '';
   }
   $items = file($database, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
   foreach($items as $line)
   {
      list($username, $password, $email, $fullname) = explode('|', trim($line));
      if ($newusername == $username)
      {
         $error_message = '';
         break;
      }
   }
   if (empty($error_message))
   {
      $file = fopen($database, 'a');
      fwrite($file, $newusername);
      fwrite($file, '|');
      fwrite($file, md5($newpassword));
      fwrite($file, '|');
      fwrite($file, $newemail);
      fwrite($file, '|');
      fwrite($file, $newfullname);
      fwrite($file, '|1|');
      fwrite($file, $code);
      fwrite($file, "\r\n");
      fclose($file);
      $subject = '';
      $message = '';
      $message .= "\r\nUsername: ";
      $message .= $newusername;
      $message .= "\r\nPassword: ";
      $message .= $newpassword;
      $message .= "\r\n";
      $header  = "From: "."\r\n";
      $header .= "Reply-To: "."\r\n";
      $header .= "MIME-Version: 1.0"."\r\n";
      $header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
      $header .= "Content-Transfer-Encoding: 8bit"."\r\n";
      $header .= "X-Mailer: PHP v".phpversion();
      mail($newemail, $subject, $message, $header);
      header('Location: '.$success_page);
      exit;
   }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Page</title>
<style type="text/css">
div#container
{
   width: 746px;
   position: relative;
   margin-top: 0px;
   margin-left: auto;
   margin-right: auto;
   text-align: left;
}
body
{
   text-align: center;
   margin: 0;
   background-color: #C0C0C0;
   color: #000000;
}
</style>
<style type="text/css">
p, span, div, ol, ul, li, td, button, input, textarea, form
{
   margin: 0;
   padding: 0;
}
a
{
   color: #0000FF;
   outline: none;
   text-decoration: underline;
}
a:visited
{
   color: #800080;
}
a:active
{
   color: #FF0000;
}
a:hover
{
   color: #376BAD;
   text-decoration: underline;
}
</style>
<style type="text/css">
#Image1
{
   border: 0px #000000 solid;
}
#Image2
{
   border: 0px #000000 solid;
}
#Image3
{
   border: 0px #000000 solid;
}
#wb_Text8 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_Text8 div
{
   text-align: left;
}
#wb_Text13 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_Text13 div
{
   text-align: center;
}
#Image8
{
   border: 0px #000000 solid;
}
#wb_Text2 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_Text2 div
{
   text-align: left;
}
.signupform_table
{
   background-color: #EDF2F8;
   border-color:#BBCEE6;
   border-width:1px;
   border-style: solid;
   color: #376BAD;
   font-family: Arial;
   font-size: 13px;
   text-align: right;
   border-spacing: 4px;
}
.signupform_header
{
   background-color: #BBCEE6;
   color: #376BAD;
   text-align: center;
}
.signupform_text
{
   background-color: #FFFFFF;
   border-color: #BBCEE6;
   border-width: 1px;
   border-style: solid;
   color: #376BAD;
   font-family: Arial;
   font-size: 13px;
}
.signupform_button
{
   background-color: #FFFFFF;
   border-color: #BBCEE6;
   border-width: 1px;
   border-style: solid;
   color: #376BAD;
   font-family: Arial;
   font-size: 13px;
}
</style>
</head>
<body>
<div id="container">
<div id="wb_Image1" style="position:absolute;left:0px;top:3px;width:746px;height:350px;z-index:0;padding:0;">
<img src="images/arriba1.jpg" id="Image1" alt="" border="0" style="width:746px;height:350px;"></div>
<div id="wb_Image2" style="position:absolute;left:0px;top:540px;width:746px;height:90px;z-index:1;padding:0;">
<img src="images/unten_banner.jpg" id="Image2" alt="" border="0" style="width:746px;height:90px;"></div>
<div id="wb_Image3" style="position:absolute;left:0px;top:300px;width:746px;height:241px;z-index:2;padding:0;">
<img src="images/mitte.jpg" id="Image3" alt="" border="0" style="width:746px;height:241px;">

</div>
<div id="wb_Shape1" style="position:absolute;left:33px;top:132px;width:680px;height:30px;z-index:3;padding:0;">
<img src="images/img0006.gif" id="Shape1" alt="" title="" style="border-width:0;width:680px;height:30px;"></div>
<div id="wb_Text8" style="position:absolute;left:45px;top:140px;width:94px;height:18px;z-index:4;">
<span style="color:#969696;font-family:Arial;font-size:15px;"><strong>Sistema PAS</strong></span></div>
<div id="wb_Text13" style="position:absolute;left:35px;top:565px;width:674px;height:11px;text-align:center;z-index:5;">
<span style="color:#000000;font-family:Tahoma;font-size:9.3px;">Creado por MANA Desarrollos</span></div>
<div id="wb_Image8" style="position:absolute;left:44px;top:52px;width:189px;height:68px;z-index:6;padding:0;">
<img src="images/logo.jpg" id="Image8" alt="" border="0" style="width:189px;height:68px;"></div>
<div id="wb_Text2" style="position:absolute;left:480px;top:97px;width:216px;height:36px;z-index:7;">
<span style="color:#969696;font-family:Arial;font-size:15px;"><strong>COLOCAR LA FECHA DEL DIA</strong></span></div>
<div id="wb_Signup1" style="position:absolute;left:33px;top:185px;width:680px;height:120px;text-align:right;z-index:8;padding:0;">
<form name="signupform" method="post" action="<?php echo basename(__FILE__); ?>" id="signupform">
  <table class="signupform_table" style="width:680px;height:80px;">
<tr>
   <td class="signupform_header" colspan="2" style="height:20px;">Baja de grupo </td>
</tr>
<tr>
   <td width="298" style="height:20px">Grupo:</td>
   <td width="370" style="text-align:left"><input class="signupform_text" name="fullname" type="text" id="fullname" style="width:150px;height:18px;"></td>
</tr>

<tr>
   <td>&nbsp;</td><td style="text-align:left;vertical-align:bottom"><input class="signupform_button" type="submit" name="signup" value="Dar de baja" id="signup" style="width:90px;height:20px;"></td>
</tr>
</table>
</form>
</div>

</div>
</body>
</html>